﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp;
using System.Globalization;
using System.Xml.Linq;

namespace PHMEE
{
    public class MainenanceAdvice : FullAuditedAggregateRoot<Guid>
    {
        protected MainenanceAdvice()
        {

        }

        public MainenanceAdvice(Guid id, string code) : base(id)
        {
            SetCode(code);
        }

        /// <summary>
        /// 故障编号
        /// </summary>
        public string Code { get; private set; }

        /// <summary>
        /// 故障类型
        /// </summary>
        public string Type { get; set; }

        /// <summary>
        /// 故障类型英文
        /// </summary>
        public string TypeEn { get; set; }

        /// <summary>
        /// 维保建议
        /// </summary>
        public string Advice { get; set; }

        /// <summary>
        /// 维保建议英文
        /// </summary>
        public string AdviceEn { get; set; }

        public MainenanceAdvice SetCode(string code)
        {
            Code = Check.NotNullOrEmpty(code, nameof(code), MaintenanceAdviceConst.MaxCodeLength);
            return this;
        }

        public string Language => CultureInfo.CurrentCulture.TwoLetterISOLanguageName;

        public string TypeDisplayName => GetTypeLocalizedName();

        public string AdviceDisplayName => GetAdviceLocalizedName();


        private string GetTypeLocalizedName()
        {
            string localizedName = Language switch
            {
                PhmeeConst.LanguageEn => TypeEn,
                _ => Type
            };

            return localizedName;
        }

        private string GetAdviceLocalizedName()
        {
            string localizedName = Language switch
            {
                PhmeeConst.LanguageEn => AdviceEn,
                _ => Advice
            };

            return localizedName;
        }

    }
}
